// pages/activityList/activityList.js
let utilApp = require('../../utils/app');
const {
  regeneratorRuntime
} = global;

Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    imgArr:[
      {
        src:'../../image/a-1.jpg',
        href:'../activity/combination/index/index'
      },
      {
        src: '../../image/a-2.jpg',
        href: '../activity/turntable/index/index'
      },
      {
        src: '../../image/a-3.jpg',
        href: '../activity/vote/index/index'
      }  
    ]
  }, 
  href(e){
      wx.navigateTo({ 
        url: e.currentTarget.dataset.href
      })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示 
   */
  onShow:async function () {
    let wxGetSetting = utilApp.promisify(wx.getSetting);
    let isUserInfo = await wxGetSetting()
    if (!isUserInfo.authSetting['scope.userInfo']) {
      utilApp.isGetUserInfo('/pages/authorization/authorization', '/pages/activityList/activityList')
    }
  }, 

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    let that = this;
    that.setData({
      sharePop: false
    })
    if (ops.from === 'button') {
      // 来自页面内转发按钮 
      console.log(ops.target)
    }
    return {
      title: '西安移动活动中心',
      path: '/pages/activity/vote/index/index',
      success: function (res) {
        // 转发成功
        wx.showToast({
          title: '转发成功',
        })
      },
      fail: function (res) {
        utilApp.showErr('分享失败', 2000)
      }
    }
  }
}) 